import pygame
from game import Game


class Wall:
    def __init__(self):
        # # 设置地图元素
        self.character_images = {
            "草墙": pygame.image.load("Img/墙.png"),
            "墙": pygame.image.load("Img/墙壁999.png"),
            "刺": pygame.image.load("Img/刺.png"),
            "纸箱": pygame.image.load("Img/纸箱.png"),
            "宝石": pygame.image.load("Img/宝石.png"),
            "宝石2": pygame.image.load("Img/宝石2.png")
        }

        self.wall_image = self.character_images["草墙"]

        self.wall_image2 = pygame.transform.scale(self.wall_image, (50, 50))
        self.f = self.wall_image2.get_rect()
        print(self.f.height)

        self.wall_rect = self.wall_image2.get_rect()
        self.wall_rect.left = 50
        self.wall_rect.top = 50

        self.wall_image3 = pygame.transform.scale(self.character_images["墙"], (50, 50))
        self.wall_image4 = pygame.transform.scale(self.character_images["刺"], (50, 20))
        self.wall_image5 = pygame.transform.scale(self.character_images["纸箱"], (50, 50))
        self.wall_image6 = pygame.transform.scale(self.character_images["宝石"], (50, 50))
        self.wall_image7 = pygame.transform.scale(self.character_images["宝石2"], (50, 50))

    def wall_display(self):
        for row in range(Game.MAP_HEIGHT):
            for col in range(Game.MAP_WIDTH):
                block = Game.wall_list[row][col]
                if block == 1:
                    Game.window.blit(self.wall_image2,
                                     (col * Game.BLOCK_SIZE, row * Game.BLOCK_SIZE, self.f.w, self.f.h))
                elif block == 2:
                    Game.window.blit(self.wall_image3,
                                     (col * Game.BLOCK_SIZE, row * Game.BLOCK_SIZE, self.f.w, self.f.h))
                elif block == 3:
                    Game.window.blit(self.wall_image4,
                                     (col * Game.BLOCK_SIZE, row * Game.BLOCK_SIZE + 30, Game.BLOCK_SIZE,
                                      Game.BLOCK_SIZE - 30))
                elif block == 4:
                    Game.window.blit(self.wall_image5,
                                     (col * Game.BLOCK_SIZE, row * Game.BLOCK_SIZE, self.f.w, self.f.h))
                elif block == 5:
                    Game.window.blit(self.wall_image6,
                                     (col * Game.BLOCK_SIZE, row * Game.BLOCK_SIZE, self.f.w, self.f.h))
                elif block == 6:
                    Game.window.blit(self.wall_image7,
                                     (col * Game.BLOCK_SIZE, row * Game.BLOCK_SIZE, self.f.w, self.f.h))
